import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import 'swiper/swiper-bundle.min.css'
import App from './App';
import reportWebVitals from './reportWebVitals';
import {BrowserRouter} from 'react-router-dom'
import axios, { AxiosRequestConfig } from 'axios'


let c = () => {
  let w = document.documentElement.clientWidth
  if (!w) return
  if (w > 750) {
      document.documentElement.style.fontSize = 10 + 'px'
  } else {
      document.documentElement.style.fontSize = 10 * (w / 750) + 'px'
  }
}
window.addEventListener('resize', c)
window.addEventListener('load', c)

axios.interceptors.request.use(
  (config:AxiosRequestConfig)=>{
    const token = localStorage.getItem('Authorization')
      if(config.headers && token){
        config.headers.token = token
      }
      return config
    },
    error=>{
      Promise.reject(error)
    }
)

ReactDOM.render(
  <React.StrictMode>
    <BrowserRouter>
      <App />
    </BrowserRouter>
  </React.StrictMode>,
  document.getElementById('root')
);



// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
